Page({
  data: {
    place:'',
    list:[],
    menu:[]
  },
  /**
   * 冯伟
   * 获取当前地理位置
   */
  getPlace(){
    wx.getLocation({
      type: 'wgs84',
      isHighAccuracy:true,
      success (res) {
        // console.log(res)
      }
     })
  },
  //获取输入框信息
  placeInfo(e){
    this.setData({
      place:e.detail.value
    })
  },
  getHouse(){
    let token=wx.getStorageSync('token')
    // console.log(token)
     wx.request({
        url: 'http://www.house.com/api/fw/getHouse',
        data:{
          token:token
        },
        success:(res)=>{
          this.setData({
            list:res.data.data
          })
        }
      })
  },
  getMenu(){
    let token=wx.getStorageSync('token')
        wx.request({
          url: 'http://www.house.com/api/fw/getMenu',
          data:{
            token:token
          },
          success:(res)=>{
            // console.log(res)
            this.setData({
              menu:res.data.data
            })
          }
        })
    
  },
  jump(e){
    let id= e.currentTarget.dataset.id
    if(id==1)
    {
      wx.redirectTo({
        url: '/pages/new/new',
      })
    }
    if(id==7)
    {
      wx.redirectTo({
        url: '/pages/broken/broken',
      })
    }
    if(id==3)
    {
      wx.redirectTo({
        url: '/pages/second_hand_house/second_hand_house',
      })
    }
    if(id==4)
    {
      wx.redirectTo({
        url: '/pages/customer/customer',
      })
    }
    if(id==5)
    {
      wx.redirectTo({
        url: '/pages/article/article',
      })
    }
    if(id==7)
    {
      wx.redirectTo({
        url: '/pages/anju/anju',
      })
    }
    if(id==8)
    {
      wx.redirectTo({
        url: '/pages/draw/draw',
      })
    }
  },
  getGpt(){
    wx.redirectTo({
      url: '/pages/gpt/gpt',
    })
  },
  //进行查找
  search(){
    let place=this.data.place
    wx.request({
      url: 'http://www.house.com/api/fw/getHouse',
      data:{
        place:place
      },
      success:(res)=>{
        this.setData({
          list:res.data.data
        })
      }
    })
  },
  onLoad() {
    this.getPlace()
    this.getHouse()
    this.getMenu()
  },
  
})
